import { BaseSys } from "../../BaseSys";
import { ComponentsMgr } from "../Components/ComponentsMgr";
import DEntity from "./DEntity";
/**
 * 实体池
 */
export class EntityPools extends BaseSys {
    private _entitys: DEntity[] = []
    public static ins(): EntityPools {
        return super.ins()
    }
    public createEntity() {
        if (this._entitys.length > 0) {
            return this._entitys.pop()
        }
        return new DEntity();
    }
    public collectionEntity(entity: DEntity) {
        ComponentsMgr.ins().removeComponents(entity.id);
        this._entitys.push(entity);
    }
}